<%@ page contentType="text/html; charset=UTF-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>  
<%@ taglib prefix="nst" uri="http://www.nstechs.com/app/core"%>  
<%@ page isELIgnored="false" %>
<script>
    var rootPath = "${pageContext.request.contextPath}";
	$(document).ready(function() {

		$('.back').click(function() {
			window.location = rootPath+"/tiles/list";
		});

		$("#Name").blur(function() {
			var name = $("#Name").val().trim();
			var desc = $("#Description").val().trim();
			if (name == "") {
				$(".name-valid").html(" * name is needed");
			} else {
				$(".name-valid").html("");
			}
		});

		$("#Description").blur(function() {
			var desc = $("#Description").val().trim();
			if (desc == "") {
				$(".desc-valid").html(" * description is needed");
			} else {
				$(".desc-valid").html("");
			}
		});

		$(".modify").click(function() {
			var name = $("#Name").val().trim();
			var desc = $("#Description").val().trim();
			if (name == "") {
				$(".name-valid").html(" * name is needed");
				$("#Name").focus();
				return;
			}
			if (desc == "") {
				$(".desc-valid").html(" * description is needed");
				return;
			}
			$(".name-valid").html("");
			$(".desc-valid").html("");
			if (desc != "" && name != "") {
				$("#uploadForm").submit();
			}
		});
	});
</script>

<div class="content" id="content" data-nav="nav_vendor">
	<div id="main">
	           <h2>Add Template</h2>
		<form id="uploadForm"
		
		     action="${pageContext.request.contextPath}/tiles/upload" enctype="multipart/form-data" method="post">
			<ul>
			      <li>
			        <label for="Description">File<span class="required">*</span></label>
			     <input id="myfile" name="template" type="file" />
				
			     </li>
		         <li>
		           <label for="Description">name<span class="required">*</span></label>
	            <input  name="name" type="text" id="Name"/>
				 <span class="name-valid" style="color:red"></span>
	            </li>
			
			   <li>
				  <label for="Description">Description<span class="required">*</span></label>
				  <textarea id="Description" cols="20" rows="2" name="description"></textarea>
				   <span class="desc-valid" style="color:red"></span>
			   </li>
			
			 
			   <li class="btnline">
				  <input class="modify" value="modify" type="button"> &nbsp; 
				  <input class="back" value="back list" type="button">
			   </li>
			</ul>
		</form>
	</div>
</div>